﻿using System;
using System.Collections.Generic;
 
using System.Text;
using System.Runtime.InteropServices;

namespace HDF5
{
    using hid_t = System.Int32;
    using herr_t = System.Int32;
    using hsize_t = System.UInt64;
    using hunsigned = System.UInt32;
    using htri_t = System.Int32;
    using ssize_t = System.Int64;
    using size_t = System.UInt64;
    using haddr_t = System.Int32;
    using hssize_t = System.Int64;
    using hbool_t = System.Boolean;
    using off_t = System.Int32;


    /*
     * Reference types allowed.
     */
    public enum H5R_type_t
    {
        H5R_BADTYPE     =   (-1),   /*invalid Reference Type                     */
        H5R_OBJECT,                 /*Object reference                           */
        H5R_DATASET_REGION,         /*Dataset Region Reference                   */
        H5R_MAXTYPE                 /*highest type (Invalid as true type)	     */
    } 

    public static class H5R
    {

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5Rcreate(IntPtr reference, hid_t loc_id, [In][MarshalAs(UnmanagedType.LPStr)] string name, H5R_type_t ref_type, hid_t space_id )  ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern hid_t H5Rdereference(hid_t obj_id, H5R_type_t ref_type, IntPtr reference ) ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern H5G_obj_t H5Rget_obj_type( hid_t loc_id, H5R_type_t ref_type, IntPtr reference ) ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5Rget_obj_type( hid_t loc_id, H5R_type_t ref_type, IntPtr reference, out H5O_type_t obj_type ) ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5Rget_obj_type2( hid_t loc_id, H5R_type_t ref_type, IntPtr reference, out H5O_type_t obj_type ) ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern hid_t H5Rget_region( hid_t loc_id, H5R_type_t ref_type, IntPtr reference ) ;

        [DllImport("hdf5dll.dll", CharSet = CharSet.Ansi)]
        public static extern ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, IntPtr reference, StringBuilder name, size_t size);
    }
}
